<?php

function old_sendRegisterMail() {

    $config = array(
        'ssl' => 'tls',
        'port' => 465,
        'auth' => 'login',
        'username' => 'macgile@gmail.com',
        'password' => 'mot&de&passe');

    $emailSmtpConf = array(
        'auth' => 'login',
        'ssl' => 'tls',
        'port' => 587,
        'username' => 'macgile@gmail.com',
        'password' => 'mot&de&passe'
    );


    //$transport = new Zend_Mail_Transport_Sendmail('-fsupport@website.com',$mailhost, $mailconfig);

    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $emailSmtpConf);
    //Use this if you do not want to specify $transport evertime you use Zend_Mail->send()
    //Zend_Mail::setDefaultTransport($transport);

    $mail = new Zend_Mail();
    $mail->setBodyText('Email body in plain text');
    $mail->setBodyHtml('Email body in HTML');
    $mail->setFrom('sender@domain.com', 'Name of sender');
    $mail->setReplyTo('sender@domain.com', 'Name of sender');
    $mail->addTo('macgile@gmail.com', 'Name of recipient');
    $mail->setSubject('Your trial at FItness First');
    $mail->send($transport);
}

class Application_Form_Patient extends Zend_Form {

    public function init() {


        $this->setDecorators(array('FormElements', 'Form')); // supprime la balise <dl>



        $elementDecorators = array(
            'ViewHelper',
            array(
                array('data' => 'HtmlTag'),
                array('tag' => 'div')
            ),
            array(
                array('openerror' => 'HtmlTag'),
                array('tag' => 'span', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)
            ),
            'Errors',
            array(
                array('closeerror' => 'HtmlTag'),
                array('tag' => 'span', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)
            ),
            array('Label',
                array('tag' => 'span')
            ),
            array(
                array('row' => 'HtmlTag'),
                array('tag' => 'div')
            )
        );

        $deco = array(
            array('ViewHelper'),
            array('Description', array('escape', false)),
            array('Errors'),
            array('HtmlTag', array('tag' => 'div')),
            array('Label', array('tag' => 'div')),
        );



        $decorators = array(
            //'Errors', array(array('err'=>'HtmlTag'), array('tag'=>'span', 'placement'=>'append')),
            // array('Errors', array('tag' => 'span', 'placement'=>'append')),
            'ViewHelper',
            'Errors',
            'Description',
            array('Description', array('tag' => 'p', 'class' => 'description')),
            array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'input')), // 3
            array('Label', array('tag' => null, 'class' => 'required')), // 2

            array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clearfix')) // 1) exterieur
        );

        $Bnt_decorators = array(
            'ViewHelper',
            array('HtmlTag', array('tag' => 'span'))
        );

        $this->setName('patient');

        $id = new Zend_Form_Element_Hidden('id_patient');
        $id->addFilter('Int')
                ->removeDecorator('DtDdWrapper')
                ->setDecorators(array('ViewHelper'));


//        $password = $this->addElement('text', 'password', array(
//            'filters' => array('StringTrim'),
//            'validators' => array(array(
//                    'StringLength', false, array(6, 10, 'messages' => array(
//                            Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short.',
//                            Zend_Validate_StringLength::TOO_LONG => 'Your password is too long.',
//                    )))),
//            'required' => true,
//            'label' => 'Your password' ));



        $nom = new Zend_Form_Element_Text('nom');
        $nom->setLabel('Nom')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setDecorators($decorators)
                ->addValidator('NotEmpty');

        $prenom = new Zend_Form_Element_Text('prenom');
        $prenom->setLabel('Prenom')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setDecorators($decorators)
                ->addValidator('NotEmpty');

        $cancel = new Zend_Form_Element_Button('cancel');
        $cancel->setLabel('Annuler')
                //->removeDecorator('Label')
                ->setAttrib('class', 'btn')
                ->setAttrib('type', 'reset')
                ->setDecorators(array('ViewHelper'))
                //->setDecorators($Bnt_decorators)
                ->setAttrib('onclick', 'window.location =\'' . $this->getView()->url(array('controller' => 'patient', 'action' => 'index')) . '\' ');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')
                //->removeDecorator('Label')
                ->setAttrib('class', 'btn primary')
                ->setDecorators(array('ViewHelper'));
        //->setDecorators($Bnt_decorators);

        $this->addElements(array($id, $nom, $prenom, $cancel, $submit));
        $this->addDisplayGroup(array('cancel', 'submit'), 'buttonGroupe');
        $this->buttonGroupe->removeDecorator('Label');
        $this->setDisplayGroupDecorators(array(
            'FormElements',
            //'Fieldset',
            //new Application_Form_Decorator_AllErrors(),
            new Zend_Form_Decorator_HtmlTag(array('tag' => 'div', 'class' => 'actions')) //wrap groups in <li>'s too
        ));

//        $this->setDecorators(array(
//            'FormElements',
//            'FormErrors',
//            'Form', array('Description', array('tag' => 'h2', 'placement' => 'PREPEND')),
//            array('HtmlTag', array('tag' => 'div', 'class' => 'write_comment')),
//        ));
    }

}

